package com.jc.gameconter.controller.appgame;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.jc.framework.enums.Conclusion;
import com.jc.framework.enums.LogType;
import com.jc.gameconter.controller.BaseController;
import com.jc.service.apilog.ApiLogService;
import com.jc.service.appgame.AppGameService;

@Controller
@RequestMapping("in")
public class AppGameController extends BaseController {
	
	@Autowired
	private AppGameService appGameService;
	
	@Autowired
	private ApiLogService apiLogService;
	
	@RequestMapping(value="total" , method = RequestMethod.GET)
	public @ResponseBody JSONObject  queryTotal(HttpServletRequest request){
		JSONObject retObject = new JSONObject();
		try {
			getLoger().error("查询app游戏总人数和总金额 -------- : ");
			
			JSONObject ret =  appGameService.queryTotal();
			return ret;
		}catch (Exception e) {
			String errorMsg = e.getMessage();
			if(StringUtils.isNotBlank(e.getMessage()) && e.getMessage().length() > 150) {
				errorMsg = StringUtils.substring(e.getMessage(), 0, 150);
			}
			retObject.put("code", "9999");
			retObject.put("msg", errorMsg);
			apiLogService.addApiLog(LogType.REQUEST_APP_GANE_TOTAL,"请求APP游戏服务器发生错误， 详情: {} , {}", Conclusion.FAIL , errorMsg , null);
			return retObject;
		}
	}
}
